package com.lagou.rpc.consumer;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author KK
 * @since 2021-09-11
 */
@RestController
public class UserController {

    private final IUserService userService;
    private final RpcClientProxy rpcClientProxy;

    public UserController(RpcClientProxy rpcClientProxy) {
        this.rpcClientProxy = rpcClientProxy;
        this.userService = (IUserService) rpcClientProxy.createProxy(IUserService.class);
    }


    @GetMapping("user")
    public User user(Integer id){
        return userService.getById(id);
    }

}
